<?php
  $options = array('inline'=>false);
  //echo $this->Html->css("menu_tight",null,$options);
  echo $this->Html->css("menu_tight_vertical",null,$options);
?>

<div class="jobGroups index panel">
	<h2><?php __('Job Groups');?></h2>
  
  <?php if ($jobGroups):?>	
  <table class="panel">
	<tr>
			<th></th>
			<th><?php echo $this->Paginator->sort('name');?></th>
      <th><?php echo $this->Paginator->sort("Alternate Name", 'JobGroupAltName.name');?></th>

	</tr>
	<?php
	$i = 0;
	foreach ($jobGroups as $jobGroup):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td>
    
      <ul class="menuTightVert shadow3">
      <?php
      // define some empty vars for passing to method for code readability (rather than passing 'null')
      $linkArgs     = null;  $separateArgs = null;   $subList = null;  $confirmMsg = null;
      $linkOptions = array();   $imgOptions =  array('class'=>'icon'); 

      // "Edit Job" menu item
      $isFirstTopMenuItem = true; $isLastTopMenuItem  = false;
      $linkDisplayStr = '';   $tooltipStr = 'Edit Group';
      $iconPath = 'Icons/White/NoCircle/32x32/pencil.png'; 
      $linkToController = 'job_groups';         $linkToMethod = 'form';
      $linkArgs = array($jobGroup['JobGroup']['id']);
      $separateArgs = true; // pass the args as separate args to the method (rather than all as one array)
      echo $this->Menu->makeListItem($linkToController, $linkToMethod, $linkArgs, $separateArgs,
                            $isFirstTopMenuItem,$isLastTopMenuItem, $linkDisplayStr, $tooltipStr, 
                            $iconPath, $subList, $linkOptions, $imgOptions, $confirmMsg );

      // "Delete" menu item
      $isFirstTopMenuItem = false; $isLastTopMenuItem  = true;
      $linkDisplayStr = ''; $tooltipStr = 'Delete Group and all its Jobs and Job Versions';
      $iconPath = 'Icons/White/NoCircle/32x32/trash.png'; 
      $linkToController = 'job_groups';         $linkToMethod = 'delete';
      $linkArgs = array($jobGroup['JobGroup']['id']);
      $separateArgs = true; // pass the args as separate args to the method (rather than all as one array)
      $confirmMsg = "Are you sure you want to delete Group '{$jobGroup['JobGroup']['name']}' " 
                          . "and ALL of its Jobs and Job Versions from the database?";
      echo $this->Menu->makeListItem($linkToController, $linkToMethod, $linkArgs, $separateArgs,
                            $isFirstTopMenuItem,$isLastTopMenuItem, $linkDisplayStr, $tooltipStr, 
                            $iconPath, $subList, $linkOptions, $imgOptions, $confirmMsg ); 
      ?>
      </ul>    
    
    </td>
    
    <td class="jobGroupName">
     <?php
      $tooltipStr = "View all Jobs for this Job Group";
      $options = array('title'=>$tooltipStr);
      echo $this->Html->link($jobGroup['JobGroup']['name'], 
                    array('controller'=>'jobs' ,'action' => 'indexByGroupId', $jobGroup['JobGroup']['id']),
                    $options); ?>
    </td>
    
    
    <td><?php echo $jobGroup['JobGroupAltName']['name']; ?>&nbsp;</td>

	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
  
  <?php else:?><p>There are currently no records to display.  
     <?php echo $this->Html->link(__('Add one now', true), array('action' => 'form')); ?></p><?php endif; ?>  
</div>